/**
 * Created by Administrator on 2017/5/25.
 */
"use strict";
//引入模块
const mongoose = require('mongoose');
const db = require('./db');

// Schema 结构
var RecommSchema = new mongoose.Schema({
    rid      :{type:Number,index: true},//rid
    bid     :{type:Number,index: true},//书id
    uid     :{type:Number,index: true},//用户id
    recomm    :{type : Number},//推荐票
    startTime    :{type : Number}//时间
});

RecommSchema.statics.findFn = function(obj,obj1, callback) {
    return this.model('Recomm').find(obj, callback).sort(obj1);
};
RecommSchema.statics.findFnLimit = function(obj,obj1,num1,callback) {
    return this.model('Recomm').find(obj).sort(obj1).limit(num1).exec(callback);
};
RecommSchema.statics.findSortOne = function(obj,obj1,callback) {
    return this.model('Recomm').findOne(obj).sort(obj1).exec(callback);
};
RecommSchema.statics.findConut = function(obj,callback) {
    return this.model('Recomm').find(obj).count().exec(callback);
};

var RecommModel = db.model('Recomm', RecommSchema);

module.exports=RecommModel;